$(function() {
	var userGrid = $("#universityLeftGrid");
	var isFinish={
		true:'<img src="public/easyui/themes/icons/ok.png">',
		false:'<img src="public/easyui/themes/icons/no.png">'
	}
	var isLoan={
		true:'<img src="public/easyui/themes/icons/ok.png">',
		false:'<img src="public/easyui/themes/icons/no.png">'
	}
	userGrid.datagrid({
		url: 'payrecord/listss',
		fit: true,
		pagination: true,
		border: false,
		fitColumns:true,
		columns: [
			[{
				field: 'checkbox',
  				width: 100,
				align: 'center',
				checkbox: true,
				hidden: false
			}, {
				field: 'id',
				width: 20,
				align: 'center',
				hidden: true
			}, {
				field: 'student',
				title: '学生姓名',
				align: 'center',
				width: 100,
				hidden: false,
				formatter: function (value, rec) {
			         return rec.student.name;
			     }
			}, {
				field: 'allMoney',
				title: '总金额',
				align: 'center',
				width: 100,
				hidden: false
			}, {

				field: 'discountMoney',
				title: '优惠金额',
				align: 'center',
				width: 100,
				hidden: false
			}, {
				field: 'discountReason',
				title: '优惠原因',
				align: 'center',
				width: 100,
				hidden: false
			}, {
				field: 'identity',
				title: '身份',
				align: 'center',
				width: 100,
				hidden: false
			}, {
				field: 'finish',
				title: '完成',
				align: 'center',
				width: 50,
				hidden: false,
				formatter : function(val){
					return isFinish[val];
				}
			}, {
				field: 'loan',
				title: '贷款',
				align: 'center',
				width: 50,
				hidden: false,
				formatter : function(val){
					return isLoan[val];
				}
			
			}]
		]/*,
		toolbar: [{
				iconCls: 'icon-redo',
				text: "导出",
				handler: function() {
					//获取复选框的选中个数
					var selRows = $('#universityLeftGrid').datagrid('getSelections');
					//判断复选框是否选中
					if(selRows.length > 0){
						//获取所选复选框中的值
						var checkedItems = $('#universityLeftGrid').datagrid('getChecked');
						var names = [];
						   $.each(checkedItems, function(index, item){
							   //获取选中学员的ID
						       names.push(item.id);
						   });	
						   $.post("hight/daoChu" + (names ? ("/" + names) : ""), function(rs) {
							   //设置表格字段隐
							});
						   var win = $.messager.progress({
								title: 'Please waiting',
								msg: '导出中'
							});
							setTimeout(function() {
								$.messager.progress('close');
								$.messager.confirm("提示", "导出成功!", function(r) {
									if(r){
										var hightGrid = $("#universitySchoolGrid");
										var hightRightGrid = $("#universityLeftGrid");
										var hightSchoolGrid = $("#universitySchoolGrid");
										hightRightGrid.datagrid("reload");
										hightSchoolGrid.datagrid("reload");
									
										}	 
								});								
							}, 3200)
					}else{
						alert("未选择任何收款记录！");
					}	
				}			
			}]*/
	});
	
	
	$("#moveinbtn").on("click",function(){
		//获取复选框的选中个数
		var selRows = $('#universityLeftGrid').datagrid('getSelections');
		//判断复选框是否选中
		if(selRows.length > 0){
			//获取所选复选框中的值
			var checkedItems = $('#universityLeftGrid').datagrid('getChecked');
			var names = [];
			$.each(checkedItems, function(index, item){
				//获取选中学员的ID
				names.push(item.id);
			 });	
			$.post("hight/daoChu" + (names ? ("/" + names) : ""), function(rs) {
			});	
			var hightGrid = $("#universitySchoolGrid");
			var hightRightGrid = $("#universityLeftGrid");
			var hightSchoolGrid = $("#universitySchoolGrid");
			hightRightGrid.datagrid("reload");
			hightSchoolGrid.datagrid("reload");			
			//将左边选择的数据删除
			var item = $('#universityLeftGrid').datagrid('getChecked');  
			if (item) {  
				for (var i = item.length - 1; i >= 0; i--) {  
				    var index = $('#universityLeftGrid').datagrid('getRowIndex', item[i]);  
				    $('#universityLeftGrid').datagrid('deleteRow', index);  
				 }  
			 } 			
		}else{
			alert("未选择任何收款记录！");
		}
	});	
	
});